package com.sddm.printServer.service.impl;


import com.sddm.printServer.entiy.CallBack;
import com.sddm.printServer.service.DefaultResponseAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;


import javax.websocket.Session;


/**
 * @author wyh
 * @version 1.0
 * @date 2022/4/7 14:56
 */
@Service
public class DefaultResponseAdapterImpl implements DefaultResponseAdapter {
    private static final Logger log = LoggerFactory.getLogger(DefaultResponseAdapterImpl.class);
    /**
     * 服务端发送消息给客户端
     */
    @Override
    public void sendMessage(CallBack callBack, Session toSession) {
        try {
            log.warn("发送给客户端的消息为{}",callBack);
            toSession.getBasicRemote().sendObject(callBack);
        }catch (Exception e){
            log.error(String.valueOf(e));
        }
    }
}
